package org.helgoboss.clc_osgi_installer

import org.helgoboss.osgi_additions._
import org.helgoboss.executable_manager.ExecutableManager


class ClcOsgiInstaller extends OsgiContext with OsgiConsumer with OsgiServiceWatcher {
    private val executableName = "clc.exe"

    whenBundleActive {
        whenServicePresent[ExecutableManager] { manager =>
            if (!manager.executableExists(executableName)) {
                val sourceUrl = bundleContext.getBundle.getResource("/" + executableName)
                val sourceInputStream = sourceUrl.openStream
                manager.installExecutable(executableName, sourceInputStream)
            }
        }
    }
}



